package com.fen.mapper;

import com.fen.entity.User;
import com.fen.service.UserService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring/spring.xml"})
public class UserMapperTest {

    private ApplicationContext context;

    private UserService userService;

    @Before
    public void before(){
        context = new ClassPathXmlApplicationContext("classpath:spring/spring.xml");

        userService = (UserService) context.getBean("userMapper");
    }

    @Test
    public void selectTest(){
        User user = userService.selectById(123);
        System.out.println("user = " + user);
    }
}
